var mongoose = require('../common/db');

var user = new mongoose.Schema({
    username: String,
    password: String,
    userMail: String,
    userPhone: String,
    userAdmin: Boolean,
    // userList: []
})

user.statics.findAll = function (name, mail, phone, userAdmin, password, callBack) {
    this.find({
        //   username: name,
        //   userMail: mail,
        //   userPhone: phone,
        //   userAdmin: userAdmin,
        //   password:password

    }, callBack);
};
user.statics.findByUsername = function (name, callBack) {
    this.find({
        username: name
    }, callBack);
};
//登录匹配
user.statics.findUserLogin = function (name, password, callBack) {
    this.find({
        username: name,
        password: password,
    }, callBack);
};
//验证邮箱和电话以及用户名找到用户
user.statics.findUserPassword = function (name, mail, phone, callBack) {
    this.find({
        username: name,
        userMail: mail,
        userPhone: phone
    }, callBack);
};




user.statics.findAdmin = function (name, userAdmin, password, callBack) {
    this.find({
        username: name,
        userAdmin: true,
        password: password,
    }, callBack);
};


var userModel = mongoose.model('user', user);
module.exports = userModel;